package java_thinking.unit_10._10_4.Exercise7;

/**
 * @Description : 10.4练习7-内部类的使用
 * 1.证明了外部类可以使用内部类的private元素
 * @author: cww
 * @DateTime: 2019-03-09 22:02
 */

class InnerClassAccess {
    private String outValue = "outValue";
    private void outMethod(){
        System.out.println(outValue);
        System.out.println("outMethod");
    }
    public class InnerChange{
        private String i = "inner.private";
        public void changeOut(){
            outValue = "InnerChange";
            outMethod();
        }
    }
    public void f(){
        InnerChange innerChange = new InnerChange();
        innerChange.changeOut();
        innerChange.i = "changeByOuter";
        System.out.println(innerChange.i);
    }

    /**
     * 匿名内部类
     */
    public void innerClass(){
        new InnerChange();
    }

}

class Eexercise7 {
    public static void main(String[] args) {
        InnerClassAccess innerClassAccess = new InnerClassAccess();
        innerClassAccess.f();
        innerClassAccess.innerClass();
    }
}
